#!/bin/bash
set -e

while getopts  ":s:p:" opts
do
	case  $opts  in
	s)
	sample_name=$OPTARG
	;;
	p)
	out_prefix=$OPTARG
	;;
	\?)
	echo `basename $0` 'sample_name'
	exit 1
	;;
	esac
done
shift $(($OPTIND - 1))

if [ -z "$1" ]; then
	echo `basename $0` 'sample_name'
	exit 1
fi


. $var  


if test -e $out_prefix.dbnsfp.snpeff2gatk.vcf; then
ln -fs $out_prefix.dbnsfp.snpeff2gatk.vcf $1.variants.vcf
fi

for file in $out_prefix.html $out_prefix.2.html 2.html $out_prefix.*.jxl.xls
do
if test -e $file; then
rename $out_prefix $1.variants $file
fi
done

for file in *.jxl.xls
do
if test -e $file;then
rename jxl. '' $file
fi
done


for file in $out_prefix.reads.stat.xls $out_prefix.summary.txt $out_prefix.interval_summ.txt $out_prefix.gene_summ.txt $out_prefix.*summary*.xls $out_prefix.*hist*.pdf $out_prefix.*freq*.pdf $out_prefix.*lorenz*.pdf ${out_prefix}*deleterious.txt ${out_prefix}*drugs-prediction*
do
if test -e $file; then
rename $out_prefix $1 $file #other part of the name should not have the same string as $out_prefix
fi
done

. $cmd_done


